<template>
  <div>
    <div>
      <van-nav-bar title="空调" right-text="···" left-arrow @click-left="onClickLeft" />
    </div>
    <div class="my_wendubox">
      <div>
        <span class="my_dutite">温度</span>
      </div>
      <div class="my_wendu">
        <div class="iconfont icon-taiyang"></div>
        <div class="my_du">27℃</div>
        <div class="iconfont icon-feng"></div>
        <div>
          <van-switch v-model="checked" active-color="#7033FF" inactive-color="#FB8F66" />
        </div>
      </div>
      <div>
        <div class="my_tu">
          <van-circle class="my_van1" v-model:current-rate="currentRate" :rate="rate1" :stroke-width="50" :size="190"
            :color="gradientColor">
            <van-circle class="my_van" v-model:current-rate="currentRate" :rate="rate" :stroke-width="120" :size="120"
              :color="gradientColor" :text="text" />
          </van-circle>
        </div>
      </div>
      <div class="my_shijian">
        <div class="my_kuan">
          <van-icon name="minus" />
        </div>
        <div>
          <div>1 1</div>
          <van-count-down :time="time" />
        </div>
        <div class="my_kuan1">
          <van-icon name="plus" />
        </div>
      </div>
      <div>
        <div ref="barChart" :style="{ width: '110x', height: '250px' }"></div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from '@/router';
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';
const time = ref(30 * 60 * 60 * 1000);
const checked = ref()

const onClickLeft = () => {
  router.push('./Hello')
}

const text = ref('27℃')
const currentRate = ref(100);
const rate = ref(60)
const rate1 = ref('100%')

const gradientColor = {
  '0%': ' #fb8f66 ',
  '100%': ' #7033ff',
};

const barChart = ref<HTMLElement>();
const myChart1 = ref<any>();
// 绘制柱形图
function initBarEcharts() {
  myChart1.value = echarts.init(barChart.value!);
  myChart1.value.setOption({
    title: {
      x: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {

      orient: 'vertical',
      right: 60,
      top: 20
    },
    xAxis: {
      data: [23, 24, 25, 26, 27, 28, 29, 30, 31],
      axisTick: {
        show: false // 不显示坐标轴刻度线
      },
      axisLine: {
        show: false, // 不显示坐标轴线
      },
    },
    yAxis: {
      show: false
    },
    color: ['#FB8F66', '#FB8F66'],
    series: [
      {
        type: 'bar',
        data: [23, 24, 18, 25, 27, 28, 25, 15, 30]
      }
    ],
    grid: {
      top: 80,
      x: 0,
      x2: 0,
      y2: 30,
    }
  });
}
onMounted(() => {
  initBarEcharts();
});

</script>

<style scoped lang="scss">
.my_wendubox {
  padding: 1rem;

  .my_dutite {
    color: #352C5D;
    font-size: 2rem;
    font-weight: 400;
    line-height: 2.44rem;
  }

  .my_wendu {
    width: 20.0rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-left: 10.0rem;
    margin-top: 1rem;

    .my_du {
      color: #FB8F66;
    }
  }

  .my_tu {
    height: 23.0rem;
    width: 23.0rem;
    border: dashed 2px #ccc;
    border-radius: 50%;
    text-align: center;
    margin-left: 6rem;
    line-height: 30.0rem;

    .my_van1 {
      margin-top: 2.0rem;
    }

    .my_van {
      width: 12.8rem;
      height: 12.8rem;
      border-radius: 50%;
      background-blend-mode: normal;
      box-shadow: 0rem 2.0rem 4.0rem rgba(112, 51, 255, 0.4);
    }
  }

  .my_shijian {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .my_kuan {
      width: 4.8rem;
      height: 4.8rem;
      background-color: #F6F5FA;
      color: #352C5D;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 2.0rem;
    }

    .my_kuan1 {
      width: 4.8rem;
      height: 4.8rem;
      background-color: #352C5D;
      color: #FFFF;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 2.0rem;
    }
  }
}
</style>